//
//  RHServiceVC.m
//  RuiHeAppApp
//
//  Created by Yan Chen on 2023/10/30.
//

#import "RHServiceVC.h"
#import "RHServiceCell.h"
#import "RHEquipmentRepairVC.h"
#import "RHQuestionVC.h"
#import "RHMoreProductVC.h"
#import "RHLearningManualVC.h"
#import "RHBrandVidioVC.h"
#import "RHNavigationController.h"
#import "RHFeedbackVC.h"
#import "RHBaseWebViewController.h"

#import "RHDocumentCenterVC.h"

@interface RHServiceVC ()<SDCycleScrollViewDelegate,UITableViewDelegate,UITableViewDataSource>
@property (nonatomic ,strong) UITableView *tableView;

@property (nonatomic ,strong) NSArray *dataArr;

@property (nonatomic ,strong) SDCycleScrollView * cycleScrollView;   // 轮播图 View

@property (nonatomic, strong) NSArray *cycleImageArr;

@property (nonatomic, strong) NSDictionary *documentDic;//文档中心数据
@end

@implementation RHServiceVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"";
    self.view.backgroundColor = CFTabViewBgColor;
    [self getProductList];
    [self setupUI];
}
-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    RHNavigationController *nav = (RHNavigationController*)self.navigationController;
    [nav setBackgoundClear:YES titleColor:nil];
}
-(void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    RHNavigationController *nav = (RHNavigationController*)self.navigationController;
    [nav setBackgoundClear:NO titleColor:nil];
}




-(void)setupUI{
    
    self.documentDic = @{CellTitle:@"文档中心".rh_localized,
                       CellContent:@[@{CellTitle:@"产品手册".rh_localized,CellIcon:@"service_manual_product",CellAction:@"goToDocument:"},
                                     @{CellTitle:@"安装手册".rh_localized,CellIcon:@"service_manual_install",CellAction:@"goToDocument:"},
                                     @{CellTitle:@"安装视频".rh_localized,CellIcon:@"service_video_extend",CellAction:@"goToVideo:"},
                                     @{CellTitle:@"推广视频".rh_localized,CellIcon:@"service_video_install",CellAction:@"goToVideo:"},
                                     @{CellTitle:@"案例分享".rh_localized,CellIcon:@"service_video_example",CellAction:@"goToVideo:"}]}
                     
    ;
    UIImageView *topBgView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"server_top_bg"]];
    
    [self.view addSubview:topBgView];
    [topBgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.mas_offset(0);
        make.height.equalTo(topBgView.mas_width).multipliedBy(250/375.0);
    }];
    
    QMUILabel *welcomeLab = [QMUILabel labelWithText:@"Hi~" font:kBOLDSYSTEMFONT(20) textColor:kCOLOR_HEX(@"#FFFFFF")];
    welcomeLab.numberOfLines = 0;
    welcomeLab.textAlignment = NSTextAlignmentLeft;
    [self.view addSubview:welcomeLab];
    [welcomeLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(15);
        make.right.mas_offset(-15);
        make.top.mas_offset(kSafe_top+15);
    }];
    
    QMUILabel *welcomeLab2 = [QMUILabel labelWithText:@"有什么可以帮您!".rh_localized font:kBOLDSYSTEMFONT(20) textColor:kCOLOR_HEX(@"#FFFFFF")];
    welcomeLab2.numberOfLines = 0;
    welcomeLab2.textAlignment = NSTextAlignmentLeft;
    [self.view addSubview:welcomeLab2];
    [welcomeLab2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(15);
        make.right.mas_offset(-15);
        make.top.equalTo(welcomeLab.mas_bottom).offset(5);
    }];
    
    _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
    [_tableView registerClass:[RHServiceCell class] forCellReuseIdentifier:@"RHServiceCell"];
    [_tableView setBackgroundColor:UIColor.clearColor];
    [_tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
    [_tableView setSeparatorColor:UIColor.clearColor];
    _tableView.estimatedRowHeight = 180;
    _tableView.rowHeight = UITableViewAutomaticDimension;
    _tableView.tableFooterView = [UIView new];
    [_tableView setDelegate:self];
    [_tableView setDataSource:self];
    _tableView.tableHeaderView = [self headerView];
    _tableView.tableFooterView = [self footerView];
    [self.view addSubview:_tableView];
    if (@available(iOS 11.0, *)) {
        _tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    }
    if (@available(iOS 13.0, *)) {
        _tableView.automaticallyAdjustsScrollIndicatorInsets = NO;
    }
    if (@available(iOS 15.0, *)) {
        _tableView.sectionHeaderTopPadding = 0;
    }
    
 
    [_tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_offset(0);
        make.top.equalTo(welcomeLab2.mas_bottom).offset(15);
        make.bottom.mas_offset(0);
    }];
    kWeakSelf;
    [_tableView addHeaderRefresh:^{
        [weakSelf getProductList];
    }];
}

#pragma mark ---- 轮播图
-(void)getProductList
{
    [BaseModel startGetWithCompletionAPIKey:H_getProductList argument:@{@"pageNum":@(1),
                                                                        @"pageSize":@(100)} requestSuccess:^(__kindof BaseRequest *request, ResultModel *resultModel) {
        [self.tableView endHeaderRefresh];
        if (resultModel.code == 200) {
            if([resultModel.rows isKindOfClass:[NSArray class]]){
                NSArray *arr = resultModel.rows;
                self.cycleImageArr = arr;
                NSMutableArray *imageArr = [NSMutableArray array];
                [arr enumerateObjectsUsingBlock:^(NSDictionary*  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
                    if ([obj[@"isOnline"] boolValue]) {
                        [imageArr addObject:ValidNullData(obj[@"imageUrl"])];
                        self.cycleScrollView.imageURLStringsGroup = imageArr;
                    }
                   
                }];
                self.tableView.tableHeaderView = [self headerView];
                [self.tableView reloadData];
            }
        }
    } requestFail:^(__kindof BaseRequest *request, ResultModel *resultModel) {
        [self.tableView endHeaderRefresh];
    }];
}




- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index
{
//    [self.navigationController pushViewController:[RHMoreProductVC new] animated:YES];
    if (self.cycleScrollView.imageURLStringsGroup.count>0) {
        if([self.cycleImageArr[index][@"productLink"] hasPrefix:@"http"]){
            RHBaseWebViewController *webVC = [[RHBaseWebViewController alloc]init];
            webVC.urlStr = self.cycleImageArr[index][@"productLink"];
            webVC.navTitle = self.cycleImageArr[index][@"productName"];
            [self.navigationController pushViewController:webVC animated:YES];
        }
        
    }
    
}

#pragma mark - UITableViewDelegate,UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 0;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return 0;
    
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 0.0;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 0.0;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
//    UIView *headView = [[UIView alloc]initWithFrame:CGRectMake(15, 0, kUI_WINDOW_W-30, 50)];
//    headView.layer.cornerRadius = 8;
//    headView.layer.masksToBounds = YES;
//    headView.layer.maskedCorners = kCALayerMinXMinYCorner|kCALayerMaxXMinYCorner;
//    headView.backgroundColor = CFTabViewBgColor;
//   
//    
//    UILabel *titleLab = [[QMUILabel alloc]init];
//    titleLab.font = kBOLDSYSTEMFONT(18);
//    titleLab.textColor = kColorRGB(0, 0, 0);
//    titleLab.textAlignment = NSTextAlignmentLeft;
//    titleLab.text = self.dataArr[section][CellTitle];
//    [headView addSubview:titleLab];
//    
//   
//    
//    [titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.mas_offset(15);
//        make.centerY.mas_offset(0);
//     }];
    
   
   return nil;
}

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 0.0;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    
    return [UIView new];
}



- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    RHServiceCell *cell = [tableView dequeueReusableCellWithIdentifier:@"RHServiceCell"];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.titleLab.text = self.dataArr[indexPath.section][CellContent][indexPath.row][CellTitle];
    cell.icon.image = [UIImage imageNamed:self.dataArr[indexPath.section][CellContent][indexPath.row][CellIcon]];
    return cell;

}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if(indexPath.row == 0){
        [self.navigationController pushViewController:[RHDocumentCenterVC new] animated:YES];
    }else if(indexPath.row == 1){
        RHBrandVidioVC *videoVC = [[RHBrandVidioVC alloc]init];
        videoVC.title = self.dataArr[indexPath.section][CellContent][indexPath.row][CellTitle];
        videoVC.index = 0;
        [self.navigationController pushViewController:videoVC animated:YES];
    }else if(indexPath.row == 2){
        RHBrandVidioVC *videoVC = [[RHBrandVidioVC alloc]init];
        videoVC.title = self.dataArr[indexPath.section][CellContent][indexPath.row][CellTitle];
        videoVC.index = 1;
        [self.navigationController pushViewController:videoVC animated:YES];
    }else if(indexPath.row == 3){
        RHBrandVidioVC *videoVC = [[RHBrandVidioVC alloc]init];
        videoVC.title = self.dataArr[indexPath.section][CellContent][indexPath.row][CellTitle];
        videoVC.index = 2;
        [self.navigationController pushViewController:videoVC animated:YES];
    }
}



-(UIView*)headerView{
    kWeakSelf;
    UIImage *circleImage = kImage(@"video_loading");
    CGFloat circle_w = (kUI_WINDOW_W - 30);
    CGFloat circle_h = circle_w * circleImage.size.height/circleImage.size.width;

    
    UIView *headerView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kUI_WINDOW_W, 250 + circle_h)];
    headerView.backgroundColor = UIColor.clearColor;
    
    [headerView addSubview: self.cycleScrollView];
    self.cycleScrollView.frame = CGRectMake(15, 0, circle_w, circle_h);
    self.cycleScrollView.hidden = self.cycleImageArr.count == 0;
    
    
    UIView *bgView = kView;
    bgView.backgroundColor = UIColor.whiteColor;
    [bgView rounded:8 width:1 color:kBorderColor];
    [headerView addSubview:bgView];
    [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        if (self.cycleImageArr.count>0) {
            make.top.equalTo(weakSelf.cycleScrollView.mas_bottom).offset(15);
        }else{
            make.top.mas_offset(0);
        }
        
        make.left.mas_offset(15);
        make.right.mas_offset(-15);
        make.bottom.mas_offset(0);
    }];
    
    QMUILabel *titleLab = [[QMUILabel alloc]init];
    titleLab.text = self.documentDic[CellTitle];
    titleLab.textColor = kCOLOR_HEX(@"#171A1D");
    titleLab.textAlignment = NSTextAlignmentRight;
    titleLab.font = kBOLDSYSTEMFONT(16);
    [bgView addSubview:titleLab];
 
    [titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_offset(15);
        make.left.mas_offset(15);
    }];
    
    NSArray *doccumentData = self.documentDic[CellContent];
   
    CGFloat item_w = (kUI_WINDOW_W - 30 - 15 - 30)/2;
    CGFloat item_h = kScaleW(70);
    NSInteger rowCount = doccumentData.count%2? doccumentData.count/2+1:doccumentData.count/2;
    
    if (self.cycleImageArr.count>0) {
        headerView.height = item_h *rowCount + 15*(rowCount+1) + 15 + circle_h;
    }else{
        headerView.height = item_h *rowCount + 15*(rowCount+1);
    }
    
    __block UIView *lastView;
    [doccumentData enumerateObjectsUsingBlock:^(NSDictionary*  _Nonnull dic, NSUInteger idx, BOOL * _Nonnull stop) {
        UIView *itemView = [[UIView alloc]init];
        itemView.layer.cornerRadius = 8;
        itemView.backgroundColor = kCOLOR_HEX(@"#F3F7FF");
        [bgView addSubview:itemView];
        
        UIImageView *img = [[UIImageView alloc]initWithImage:[UIImage imageNamed:dic[CellIcon]]];
        [itemView addSubview:img];
         
        QMUILabel *titleLab = [[QMUILabel alloc]init];
        titleLab.numberOfLines = 0;
        titleLab.text = dic[CellTitle];
        titleLab.font = kSYSTEMFONT(14);
        titleLab.textColor = kCOLOR_HEX(@"#171A1D");
        [itemView addSubview:titleLab];
        
        QMUIButton *btn = [[QMUIButton alloc]init];
        [itemView addSubview:btn];
        [[btn rac_signalForControlEvents:UIControlEventTouchUpInside]subscribeNext:^(__kindof UIControl * _Nullable x) {
            SEL selector = NSSelectorFromString(dic[CellAction]);
            if([weakSelf respondsToSelector:selector]){
                [weakSelf performSelector:selector withObject:@(idx)];
            }
        }];
        
        [img mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.height.offset(25);
            make.left.mas_offset(15);
            make.centerY.mas_offset(0);
        }];
        
        [titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(img.mas_right).offset(10);
            make.right.mas_offset(-15);
            make.centerY.equalTo(img);
        }];
        
        
        [btn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.insets(UIEdgeInsetsZero);
        }];
        
        if(idx == 0){
            [itemView mas_makeConstraints:^(MASConstraintMaker *make) {
                make.top.mas_offset(15);
                make.left.mas_offset(15);
                make.width.offset(item_w);
                make.height.offset(item_h);
            }];
        }else{
            if(idx%2==0){
                [itemView mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.left.mas_offset(15);
                    make.top.equalTo(lastView.mas_bottom).offset(15);
                    make.size.equalTo(lastView);
                }];
            }else{
                [itemView mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.left.equalTo(lastView.mas_right).offset(15);
                    make.top.equalTo(lastView);
                    make.size.equalTo(lastView);
                }];
            }
        }
        lastView = itemView;
    }];
    
    
    return headerView;
}

-(UIView*)footerView{
    //746 342

    CGFloat item_w = (kUI_WINDOW_W - 30 - 15)/2;

    UIView *footerView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kUI_WINDOW_W, 280)];
    footerView.backgroundColor = UIColor.clearColor;
    
    NSArray *titles = @[@"设备报修".rh_localized,@"意见反馈".rh_localized,@"常见问题".rh_localized];
    NSArray *subTitles = @[@"权威认证".rh_localized,@"合作共赢".rh_localized,@"快速查看".rh_localized];
    NSArray *colors = @[@"#425CA1",@"#9C563B",@"#38704E"];
    NSArray *bgColors = @[@"#E6ECFF",@"#FFECE5",@"#DEF9EF"];
    NSArray *actions = @[@"goToRepair",@"goToFeedback",@"goToQuestion"];
    NSArray *icons = @[@"kwt_server_repair",@"kwt_server_feedback",@"kwt_server_question"];
    NSLog(@"---->当前用户:%@", [PrivateMange share].currentUser.yy_modelDescription);
    
    if([PrivateMange share].currentUser.orgType != OrganizationTypeUser){//除用户层级以外
        titles = @[@"常见问题".rh_localized,@"意见反馈".rh_localized];
        subTitles = @[@"快速查看".rh_localized,@"合作共赢".rh_localized];
        colors = @[@"9C563B",@"38704E"];
        bgColors = @[@"#E6ECFF",@"#FFECE5",@"#DEF9EF"];
        actions = @[@"goToQuestion",@"goToFeedback"];
        icons = @[@"kwt_server_question",@"kwt_server_feedback"];
    }
    
    __block UIView *lastView;
    kWeakSelf;
    [titles enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        UIView *bgView = [[UIView alloc]init];
        bgView.layer.cornerRadius = 8;
        bgView.backgroundColor = kCOLOR_HEX(bgColors[idx]);
        [footerView addSubview:bgView];
        
        UIImageView *img = [[UIImageView alloc]initWithImage:[UIImage imageNamed:icons[idx]]];
        [bgView addSubview:img];
         
        QMUILabel *titleLab = [[QMUILabel alloc]init];
        titleLab.numberOfLines = 0;
        titleLab.text = titles[idx];
        titleLab.font = [UIFont boldSystemFontOfSize:15];
        titleLab.textColor = kCOLOR_HEX(colors[idx]);
        [bgView addSubview:titleLab];
        
        QMUILabel *subTitleLab = [[QMUILabel alloc]init];
        subTitleLab.text = subTitles[idx];
        subTitleLab.numberOfLines = 2;
        subTitleLab.adjustsFontSizeToFitWidth = YES;
        subTitleLab.minimumScaleFactor = 0.6;
        subTitleLab.font = [UIFont systemFontOfSize:10];
        if (idx == 1) {
            subTitleLab.font = [UIFont systemFontOfSize:12];
        }
        subTitleLab.textColor = kCOLOR_HEX(colors[idx]);
        subTitleLab.numberOfLines = 0;
        [bgView addSubview:subTitleLab];
        
        QMUIButton *btn = [[QMUIButton alloc]init];
        [bgView addSubview:btn];
        [[btn rac_signalForControlEvents:UIControlEventTouchUpInside]subscribeNext:^(__kindof UIControl * _Nullable x) {
            SEL selector = NSSelectorFromString(actions[idx]);
            if([weakSelf respondsToSelector:selector]){
                [weakSelf performSelector:selector];
            }
        }];
        
        //终端用户
        if([PrivateMange share].currentUser.orgType == OrganizationTypeUser){            
            if (idx == 0) {
                [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.left.mas_offset(15);
                    make.width.offset(item_w);
                    make.top.mas_offset(15);
                    make.height.offset(180);
                }];
                
                [img mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.width.height.offset(75);
                    make.right.mas_offset(-10);
                    make.bottom.mas_offset(-15);
                }];
                
                [titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.top.mas_offset(20);
                    make.left.mas_offset(15);
                    make.right.mas_offset(-15);
                }];
                
                [subTitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.left.equalTo(titleLab);
                    make.top.equalTo(titleLab.mas_bottom).offset(10);
                    make.right.mas_offset(-10);
                }];
                
                
                [btn mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.edges.insets(UIEdgeInsetsZero);
                }];
                
            }
            
            if (idx == 1) {
                [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.left.equalTo(lastView.mas_right).offset(15);
                    make.width.offset(item_w);
                    make.top.equalTo(lastView);
                    make.height.equalTo(lastView).multipliedBy(0.5).offset(-7.5);
                }];
                
                [img mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.width.height.offset(45);
                    make.right.mas_offset(-10);
                    make.top.mas_offset(10);
                }];
                
                [titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.top.mas_offset(20);
                    make.left.mas_offset(15);
                    make.right.mas_offset(-15);
                }];
                
                [subTitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.left.equalTo(titleLab);
                    make.top.equalTo(titleLab.mas_bottom).offset(10);
                    make.right.mas_offset(-10);
                }];
                
                
                [btn mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.edges.insets(UIEdgeInsetsZero);
                }];
            }
            
            if (idx == 2) {
                [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.left.equalTo(lastView);
                    make.width.offset(item_w);
                    make.top.equalTo(lastView.mas_bottom).offset(15);
                    make.height.equalTo(lastView);
                }];
                
                [img mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.width.height.offset(45);
                    make.right.mas_offset(0);
                    make.top.mas_offset(10);
                }];
                
                [titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.top.mas_offset(20);
                    make.left.mas_offset(15);
                    make.right.mas_offset(-15);
                }];
                
                [subTitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.left.equalTo(titleLab);
                    make.top.equalTo(titleLab.mas_bottom).offset(10);
                    make.right.mas_offset(-10);
                }];
                
                
                [btn mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.edges.insets(UIEdgeInsetsZero);
                }];
            }
        }else{
            //终端以上 及 普通用户
            if (idx == 0) {
                [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.left.mas_offset(15);
                    make.width.offset(item_w);
                    make.top.mas_offset(15);
                    make.height.offset(180);
                }];
            }else{
                [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.left.equalTo(lastView.mas_right).offset(15);
                    make.width.height.equalTo(lastView);
                    make.top.equalTo(lastView);
                }];
            }
            [img mas_makeConstraints:^(MASConstraintMaker *make) {
                make.width.height.offset(75);
                make.right.mas_offset(-10);
                make.bottom.mas_offset(-15);
            }];
            
            [titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
                make.top.mas_offset(20);
                make.left.mas_offset(15);
                make.right.mas_offset(-15);
            }];
            
            [subTitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(titleLab);
                make.top.equalTo(titleLab.mas_bottom).offset(10);
                make.right.mas_offset(-10);
            }];
            
            
            [btn mas_makeConstraints:^(MASConstraintMaker *make) {
                make.edges.insets(UIEdgeInsetsZero);
            }];
           
        }
        
        lastView = bgView;
    }];
    
    return footerView;
}

-(void)goToDocument:(NSNumber*)index
{
    NSInteger idx = [index integerValue];
    NSInteger type = 0;
    if (idx == 0) {
        type = 1;//产品手机
    }else if (idx == 1){
        type = 0;//安装手册
    }
    NSArray * documentArr = self.documentDic[CellContent];
    NSDictionary *dic = documentArr[idx];
    RHDocumentCenterVC *manualVC = [[RHDocumentCenterVC alloc]init];
    manualVC.title = dic[CellTitle];
    manualVC.type = type;
    [self.navigationController pushViewController:manualVC animated:YES];
}

-(void)goToVideo:(NSNumber*)index
{
    NSInteger idx = [index integerValue];
    NSInteger type = 0;
    if (idx == 2) {
        type = 0;//安装视频
    }else if (idx == 3){
        type = 1;//推广视频
    }else if (idx == 4){
        type = 2;//案例分享
    }
    NSArray * documentArr = self.documentDic[CellContent];
    NSDictionary *dic = documentArr[idx];
    RHBrandVidioVC *videoVC = [[RHBrandVidioVC alloc]init];
    videoVC.title = dic[CellTitle];
    videoVC.index = type;
    [self.navigationController pushViewController:videoVC animated:YES];
}


-(void)goToRepair
{
    RHEquipmentRepairVC *vc = [[RHEquipmentRepairVC alloc] init];
    vc.canSelectDevice = YES;
    vc.finishBlock = ^{
        
    };
    [self.navigationController pushViewController:vc animated:YES];
}

-(void)goToFeedback
{
    [self.navigationController pushViewController:[RHFeedbackVC new] animated:YES];
}

-(void)goToQuestion
{
    [self.navigationController pushViewController:[RHQuestionVC new] animated:YES];
}

-(void)goToService
{
    RHBaseWebViewController *webVC = [[RHBaseWebViewController alloc]init];
    webVC.navTitle = @"智能客服".rh_localized;
    webVC.urlStr = @"https://www.ruihenergy.com";
    [self.navigationController pushViewController:webVC animated:YES];
}


-(SDCycleScrollView *)cycleScrollView{
    if (!_cycleScrollView) {
        _cycleScrollView = [SDCycleScrollView cycleScrollViewWithFrame: CGRectMake(15, 0, 0, 0) delegate: self placeholderImage: kImage(@"video_loading")];
        _cycleScrollView.backgroundColor = UIColor.clearColor;
        _cycleScrollView.pageControlAliment = SDCycleScrollViewPageContolAlimentCenter;
        _cycleScrollView.autoScrollTimeInterval = 5;
        _cycleScrollView.pageControlStyle = SDCycleScrollViewPageContolStyleClassic;
        _cycleScrollView.showPageControl = YES;
        _cycleScrollView.delegate = self;
        _cycleScrollView.userInteractionEnabled = YES;
        _cycleScrollView.backgroundColor = [UIColor whiteColor];
        [_cycleScrollView.layer setCornerRadius:8];
        [_cycleScrollView.layer setMasksToBounds:YES];
        _cycleScrollView.delegate = self;
        _cycleScrollView.pageControlDotSize = CGSizeMake(8, 8);
        _cycleScrollView.currentPageDotColor = [UIColor whiteColor];;
        _cycleScrollView.pageDotColor = [UIColor colorWithHexString:@"FFFFFF" alpha:0.4];
    //    _cycleScrollView.imageURLStringsGroup = @[@"home_circle01",@"home_circle02",@"home_circle03"];
        _cycleScrollView.bannerImageViewContentMode = UIViewContentModeScaleAspectFill;
    }
    return _cycleScrollView;
}
@end
